package com.twu.biblioteca;

import com.twu.biblioteca.core.InvalidMenuOptionException;
import com.twu.biblioteca.core.Menu;
import com.twu.biblioteca.core.Option;
import com.twu.biblioteca.core.User;
import com.twu.biblioteca.util.Cli;

public class BibliotecaApp {

    private String welcomeMessage;
    private Menu menu;
    private User currentUser;

    private Cli cli;

    public static void main(String[] args) {
        BibliotecaApp app = BibliotecaAppFactory.createBibliotecaApp();
        app.run();
    }

    public void run() {
        cli.output(welcomeMessage);
        while (true) {
            try {
                Option option = menu.promptOption();
                option.execute();
            } catch (InvalidMenuOptionException e) {
                cli.output(e.getMessage());
            }
        }
    }

    public void setWelcomeMessage(String welcomeMessage) {
        this.welcomeMessage = welcomeMessage;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }


    public boolean isAlreadyLogin() {
        return currentUser != null;
    }

    public void setCurrentUser(User user) {
        this.currentUser = user;
    }

    public User getCurrentUser() {
        return currentUser;
    }

    public void setCli(Cli cli) {
        this.cli = cli;
    }

    public Cli getCli() {
        return cli;
    }
}